<script>
export default {
	name: 'Copy',
	functional: true,
	props: {
		copy: {
			type: Function,
			default: () => {}
		},
		title: {
			type: [String, Number],
			default: ''
		},
		textColor: {
			type: Boolean,
			default: false
		}
	},
	// eslint-disable-next-line vue/require-render-return
	render(h, context) {
		const { title, copy, textColor } = context.props
		if (title) {
			const txtColor = {
				color: '#409EFF'
			}
			return (
				<span
					style='cursor: pointer;overflow: hidden;text-overflow: ellipsis;'
					onClick={() => copy(String(title))}
				>
					<span style={textColor ? txtColor : ''}>{title}</span>
					<i class='el-icon-document-copy' />
				</span>
			)
		} else {
			return <p style='cursor: pointer'>{'-'}</p>
		}
	}
}
</script>
